package cn.stylefeng.guns.modular.business.controller;

import cn.stylefeng.guns.modular.business.pojo.RiverManagementRequest;
import cn.stylefeng.guns.modular.business.service.RiverManagementService;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import io.swagger.annotations.Api;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 河道管理控制器
 *
 * @author zhangyaowen
 * @date 2021/10/08 16:51
 */
@RestController
@ApiResource(name = "河道管理")
public class RiverManagementController {

    @Resource
    private RiverManagementService riverManagementService;

    /**
     * 添加
     *
     * @author zhangyaowen
     * @date 2021/10/08 16:51
     */
    @PostResource(name = "添加", path = "/riverManagement/add")
    public ResponseData add(@RequestBody @Validated(RiverManagementRequest.add.class) RiverManagementRequest riverManagementRequest) {
        riverManagementService.add(riverManagementRequest);
        return new SuccessResponseData();
    }

    /**
     * 删除
     *
     * @author zhangyaowen
     * @date 2021/10/08 16:51
     */
    @PostResource(name = "删除", path = "/riverManagement/delete")
    public ResponseData delete(@RequestBody @Validated(RiverManagementRequest.delete.class) RiverManagementRequest riverManagementRequest) {
        riverManagementService.del(riverManagementRequest);
        return new SuccessResponseData();
    }

    /**
     * 编辑
     *
     * @author zhangyaowen
     * @date 2021/10/08 16:51
     */
    @PostResource(name = "编辑", path = "/riverManagement/edit")
    public ResponseData edit(@RequestBody @Validated(RiverManagementRequest.edit.class) RiverManagementRequest riverManagementRequest) {
        riverManagementService.edit(riverManagementRequest);
        return new SuccessResponseData();
    }

    /**
     * 查看详情
     *
     * @author zhangyaowen
     * @date 2021/10/08 16:51
     */
    @GetResource(name = "查看详情", path = "/riverManagement/detail")
    public ResponseData detail(@Validated(RiverManagementRequest.detail.class) RiverManagementRequest riverManagementRequest) {
        return new SuccessResponseData(riverManagementService.detail(riverManagementRequest));
    }

    /**
     * 获取列表
     *
     * @author zhangyaowen
     * @date 2021/10/08 16:51
     */
    @GetResource(name = "获取列表", path = "/riverManagement/list")
    public ResponseData list(RiverManagementRequest riverManagementRequest) {
        return new SuccessResponseData(riverManagementService.findList(riverManagementRequest));
    }

    /**
     * 获取列表（带分页）
     *
     * @author zhangyaowen
     * @date 2021/10/08 16:51
     */
    @GetResource(name = "分页查询", path = "/riverManagement/page")
    public ResponseData page(String name) {
        RiverManagementRequest riverManagementRequest = new RiverManagementRequest();
        riverManagementRequest.setRiverName(name);
        return new SuccessResponseData(riverManagementService.findPage(riverManagementRequest));
    }

    /**
     * 获取河道管理详情
     *
     * @param id
     * @return
     */
    @GetResource(name = "河道管理详情", path = "/riverManagement/toReview")
    public ResponseData toReview(String id) {
        return new SuccessResponseData(riverManagementService.toReview(id));
    }
}